SHARED
Section: Memory Management Utilities ()
Updated: June 12 1992
Index
Return to Main Contents
NAME
Shared - A mixin class to provides a reference count for shared objects.
SYNOPSIS
#include <cool/Shared.h>
DESCRIPTION
Shared is a mixin class, which stores the number of references
to an object, pointed to by pointers or handles. Shared does not have
a virtual destructor, and so deletion of the shared object must be done
with explicit type by whoever calls dereference().
BASE CLASSES
None.
FRIEND CLASSES
None.
CONSTRUCTORS
- inline Shared();
-
Creates a Shared instance and initializes the reference count to 0.
- inline ~Shared();
-
Nothing. Destructor is not virtual. Deletion of shared objects
has to be done by the caller of dereference(), for example
the Handle<Type> class, and not by the Shared class.
MEMBER FUNCTIONS
- inline int reference_count();
-
Returns the current reference count on the shared object.
- inline int reference();
-
Increments the reference count on the shared object, and returns
the new count.
- inline int dereference();
-
Decrements the reference count on the shared object, and returns
the new count.
- static inline int reference(Shared* ptr);
-
- static inline int dereference(Shared* ptr);
-
If pointer ptr is null then noop, else increments and decrements
reference count, and returns the new count.
FRIEND FUNCTIONS
None.
EXAMPLE
To make your class Vector<Type> a shared one, so that you can use
handles Handle<Vector<Type>>, simply inherits publicly from
Shared mixin class, as below:
Before:
class Vector<Type> : public Vector { ... };
Now:
class Vector<Type> : public Vector, public Shared { ... };
SEE ALSO
Handle class which implements a smart pointer that increments,
decrements, and calls destructor on the shared objects as necessary.
COPYRIGHT
Copyright (C) 1992 General Electric Company.
Permission is granted to any individual or institution to use, copy, modify,
and distribute this software, provided that this complete copyright and
permission notice is maintained, intact, in all copies and supporting
documentation.
General Electric Company provides this software "as is" without
express or implied warranty.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- BASE CLASSES
-
- FRIEND CLASSES
-
- CONSTRUCTORS
-
- MEMBER FUNCTIONS
-
- FRIEND FUNCTIONS
-
- EXAMPLE
-
- SEE ALSO
-
- COPYRIGHT
-
This document was created by
man2html,
using the manual pages.
Time: 00:40:36 GMT, March 30, 2022